package org.crud4j.wicket.markup.html.edit;

import java.util.List;

import org.apache.wicket.markup.html.basic.Label;
import org.apache.wicket.markup.html.list.ListItem;
import org.apache.wicket.markup.html.list.ListView;
import org.crud4j.core.CrudField;
import org.crud4j.wicket.markup.html.editor.EditorFactory;

public class EditFormList extends ListView {

	private static final long serialVersionUID = 1L;

	public EditFormList(String id, List fields) {
		super(id, fields);
		setReuseItems(true);
	}

	@Override
	protected void populateItem(ListItem item) {
		CrudField field = (CrudField) item.getModelObject();
		item.add(new Label("label", field.getDef().getLabel()));
		item.add(EditorFactory.getEditor("editor", field));
	}

}
